package com.jl.obulibrary.sdk;

import com.jl.obulibrary.driver.LocalPsamSerialDriver;
import com.jl.obulibrary.driver.PasmHead;
import com.jl.obulibrary.servive.OperationByPsam;
import com.xfkj.etcpos.core.exceps.CryptographyEngineException;

public class SDK_PSAM {


    /**
     * PSAM卡初始化
     */
    public static void PsamReset(int index)  {
        if (index==1) {
            LocalPsamSerialDriver.setCurrentSock(PasmHead.ICC_SOCK_PSAM1);
        }else if (index==2)  {
            LocalPsamSerialDriver.setCurrentSock(PasmHead.ICC_SOCK_PSAM2);
        }
        try {
            OperationByPsam.getInstance().PsamReset() ;
        } catch (CryptographyEngineException e) {
            e.printStackTrace();
        }

    }
    /**
     * PSAM卡发送Cos指令
     */
    public static String PsamCos(int index,String cos) {
        if (index==1) {
            LocalPsamSerialDriver.setCurrentSock(PasmHead.ICC_SOCK_PSAM1);
        }else if (index==2)  {
            LocalPsamSerialDriver.setCurrentSock(PasmHead.ICC_SOCK_PSAM2);
        }

        try {
            String s = OperationByPsam.getInstance().PsamApdu(cos);
            return s;
        } catch (CryptographyEngineException e) {
            e.printStackTrace();
            return "";
        }

    }
}
